var dialogManager = require("dialogManager");
cc.Class({
    extends: cc.Component,

    properties: {
        imgEffect : {
            default : null,
            type : cc.Node
        },
        imgMusic : {
            default : null,
            type : cc.Node
        },
        musicSet:false,
        effectSet:false,
        sprArr :{
            default:[],
            type:[cc.SpriteFrame],
        }
    },
    onLoad () {},
    start () {
        this.effectSet = cc.sys.localStorage.getItem("sfxVolume");
        this.musicSet = cc.sys.localStorage.getItem("bgmVolume");

        if(this.effectSet == 1){
            this.imgEffect.getComponent(cc.Sprite).spriteFrame = this.sprArr[1];
        }else{
            this.imgEffect.getComponent(cc.Sprite).spriteFrame = this.sprArr[0];
        }

        if(this.musicSet == 1){
            this.imgMusic.getComponent(cc.Sprite).spriteFrame = this.sprArr[1];
        }else{
            this.imgMusic.getComponent(cc.Sprite).spriteFrame = this.sprArr[0];
        }
    },
    show(){},
    musicClick(){
        if(this.musicSet == 1){
            this.musicSet = 0;
            this.imgMusic.getComponent(cc.Sprite).spriteFrame = this.sprArr[0];
            cc.vv.audioMgr.setBGMVolume(0);
        }else{
            this.musicSet = 1;
            this.imgMusic.getComponent(cc.Sprite).spriteFrame = this.sprArr[1];
            cc.vv.audioMgr.setBGMVolume(1);
        }
        cc.vv.audioMgr.playSFX("ui_button");
    },
    effectClick(){
        if(this.effectSet == 1){
            this.effectSet = false;
            this.imgEffect.getComponent(cc.Sprite).spriteFrame = this.sprArr[0];
            cc.vv.audioMgr.setSFXVolume(0);
        }else{
            this.effectSet = true;
            this.imgEffect.getComponent(cc.Sprite).spriteFrame = this.sprArr[1];
            cc.vv.audioMgr.setSFXVolume(1);
        }
        cc.vv.audioMgr.playSFX("ui_button");
    },
    helpClick(){
        cc.vv.audioMgr.playSFX("ui_button");
        dialogManager.showHelpDialog();
    },
    closeClick(){
        this.node.destroy();
        cc.vv.audioMgr.playSFX("ui_button");
    },
});
